package com.yanqu.road.server.cmd.activity.huashigang;

import com.yanqu.road.pb.huashigang.HuaShiGangProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.cross.battle.HuaShiGangMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;


@Cmd(code = CrossProtocol.C2_HUA_SHI_GANG_GET_ELITE_REWARD, desc = "领取精英怪奖励")
public class CrossGetEliteRewardCmd extends CrossCommand {

    private int activityId;

    private int y;

    private boolean oneKey;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        HuaShiGangProto.CrossGetEliteRewardReqMsg reqMsg = HuaShiGangProto.CrossGetEliteRewardReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        y = reqMsg.getY();
        oneKey = reqMsg.hasOneKey() && reqMsg.getOneKey();
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        if (oneKey) {
            HuaShiGangMgr.getEliteRewardOneKey(activityId, serverId, packet.getPlayerId());
        } else {
            HuaShiGangMgr.getEliteReward(activityId, serverId, packet.getPlayerId(), y);
        }
    }

    @Override
    public void sendData() {

    }
}
